<template>
  <div>
    <el-skeleton v-show="isLoading" :rows="6" animated />
    <div v-show="!isLoading" class="new-album-list">
        <div class="time-info">
            <div class="time-info-content">本周新碟</div>
        </div>
        <div class="data-list">
            <ImgList :list="weekData" type="album" @clickImg="toAlbumDetail">
                <template v-slot="{item}">
                    <div class="text-hidden">
                        {{item.name}}
                    </div>
                </template>
            </ImgList>
        </div>
    </div>
  </div>
</template>

<script>
import { getTopAlbum } from "@/api/request";
import ImgList from "@/components/list/ImgList.vue"
export default {
    components:{
        ImgList
    },
  data() {
    return {
      queryInfo: {
        area: "ALL",
        type: "new",
        year: "",
        month: "",
      },
      isLoading:true,
      weekData:[]
    };
  },
  created(){    
    this.getNewAlbum();
  },
  methods:{
    async getNewAlbum(){
        this.isLoading = true;
        const {data:res} = await getTopAlbum(this.queryInfo)
        console.log(res);
        if(res.code !== 200) return;
        if(Object.hasOwnProperty.call(res,'weekData')){
            this.weekData = Object.freeze(res.weekData);
        } else {
            this.weekData = [];
        }
        this.isLoading = false ;
    },
    toAlbumDetail(id){
        this.$router.push("/albumdetail/" + id);
    }
  }
};
</script>

<style lang="less" scoped>
.new-album-list{
    display: flex;
    width: 100%;
    .time-info{
        width: 50px;
        text-align: center;
        &-content{
            font-size: 20px;
            width: 30px;
        }
    }
}
</style>